home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.09 Sep 90 / Object1 Folder / CObject1Pane.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-05  |  3.0 KB  |  121 lines  |  [TEXT/KAHL]

  1. /****
  2.  * CObject1Pane.c
  3.  *
  4.  *    Pane methods for a typical application.
  5.  *
  6.  *    Most applications will want a scrollable window, so this
  7.  *    class is based on the class CPanorama. All the methods here
  8.  *    would still apply to classes based directly on CPane.
  9.  *
  10.  ****/
  11.  
  12. #include "CObject1Pane.h"
  13.  
  14. void CObject1Pane::IObject1Pane(CView *anEnclosure, CBureaucrat *aSupervisor,
  15.                             short aWidth, short aHeight,
  16.                             short aHEncl, short aVEncl,
  17.                             SizingOption aHSizing, SizingOption aVSizing)
  18. {
  19.     CPanorama::IPanorama(anEnclosure, aSupervisor, aWidth, aHeight,
  20.                             aHEncl, aVEncl, aHSizing, aVSizing);
  21. }
  22.  
  23. /***
  24.  * Draw
  25.  *
  26.  *    In this method, you draw whatever you need to display in
  27.  *    your pane. The area parameter gives the portion of the 
  28.  *    pane that needs to be redrawn. Area is in frame coordinates.
  29.  *
  30.  ***/
  31.  
  32. void CObject1Pane::Draw(Rect *area)
  33.  
  34. {    /* draw your stuff */
  35.     /* I put my stuff in a seperate function to cut compilation time. */
  36.  
  37.     DrawMyStuff(); 
  38.     
  39. }
  40.  
  41. /***
  42.  * DoClick
  43.  *
  44.  *    The mouse went down in the pane.
  45.  *    In this method you do whatever is appropriate for your
  46.  *    application. HitPt is given in frame coordinates. The other
  47.  *    parameters, modiferKeys and when, are taken from the event
  48.  *    record.
  49.  *
  50.  *    If you want to implement mouse tracking, this is the method
  51.  *    to do it in. You need to create a subclass of CMouseTask and
  52.  *    pass it in a TrackMouse() message to the pane.
  53.  *
  54.  ***/ 
  55.  
  56. void CObject1Pane::DoClick(Point hitPt, short modifierKeys, long when)
  57.  
  58. {
  59.     /* what happens when the mouse goes down */
  60. }
  61.  
  62.  
  63. /***
  64.  * HitSamePart
  65.  *
  66.  *    Test whether pointA and pointB are in the same part.
  67.  *    "The same part" means different things for different applications.
  68.  *    In the default method, "the same part" means "in the same pane."
  69.  *    If you want a different behavior, override this method. For instance,
  70.  *    two points might be in the same part if they're within n pixels
  71.  *    from each other.
  72.  *
  73.  *    PointA and pointB are both in frame coordinates.
  74.  *
  75.  ***/
  76.  
  77. Boolean     CObject1Pane::HitSamePart(Point pointA, Point pointB)
  78.  
  79. {
  80.     return inherited::HitSamePart(pointA, pointB);
  81. }
  82.  
  83.  
  84. /***
  85.  * AdjustCursor
  86.  *
  87.  *    If you want the cursor to have a different shape in your pane,
  88.  *    do it in this method. If you want a different cursor for different
  89.  *    parts of the same pane, you'll need to change the mouseRgn like this:
  90.  *        1. Create a region for the "special area" of your pane.
  91.  *        2. Convert this region to global coordinates
  92.  *        3. Set the mouseRgn to the intersection of this region
  93.  *           and the original mouseRgn: SectRgn(mouseRgn, myRgn, mouseRgn);
  94.  *
  95.  *    The default method just sets the cursor to the arrow. If this is fine
  96.  *    for you, don't override this method.
  97.  *
  98.  ***/
  99.  
  100. void CObject1Pane::AdjustCursor(Point where, RgnHandle mouseRgn)
  101.  
  102. {
  103.     inherited::AdjustCursor(where, mouseRgn);
  104. }
  105.  
  106.  
  107. /***
  108.  * ScrollToSelection
  109.  *
  110.  *    If your pane is based on a Panorama (as this example is), you might
  111.  *    want to define what it means to have a selection and what it means to
  112.  *    scroll to that selection.
  113.  *
  114.  ***/
  115.  
  116. void CObject1Pane::ScrollToSelection(void)
  117.  
  118. {
  119.     /* scroll to the selection */
  120. }
  121.